<?php
declare(strict_types = 1);
namespace app\admin\middleware;

class Auth
{
    public function handle($request, \Closure $next)
    {
        //前置中间件
        if(empty(session(config("admin.session_admin"))) && !preg_match("/login/",$request->pathinfo())){
            return redirect((string)url("login/index"));
        }

        $response = $next($request);
        //if(empty(session(config("admin.session_admin"))) && $request->controller() != 'Login'){
          //  return redirect((string)url("login/index"));
        //}
        return $response;
        //后置中间件
    }


    /**
     * 中间件结束调度
     * @param \think\Response $response
     * @return void
     */
    public function end(\think\Response $response)
    {

    }
}